import { rcaNumberFormat } from './common.js'
import { dateFormat } from '@/util/date';
import { commonTableOption } from './common.js'

function noDiff (val) {
  return val === undefined || val === 0
}
export const startDate = dateFormat(new Date(), 'yyyy-MM-') + '01';
export const endDate = dateFormat(new Date(), 'yyyy-MM-dd');
export const tableOption = {
  ...commonTableOption,
  page: false,
  selection: true,
  showSummary: true,
  height: '400px',
  // selectable: (row, index) => {
  //   return (
  //     row.confirmStatus === '0'
  //     // noDiff(row.diffAlipyAmount) &&
  //     // noDiff(row.diffWechartAmount) &&
  //     // noDiff(row.diffUnionpayBankAmount)
  //   );
  // },
  column: [
    {
      label: '支付宝、微信、银联交易统计表',
      children: [{
        type: 'date',
        label: '交易日期',
        prop: 'tradeDate',
        searchSpan: 12,
        searchRange: true,
        search: true,
        searchValue: [startDate, endDate],      // 这是我获取的默认的显示日期，我这里是['2020-08-04', '2020-09-22']
        format: 'yyyy-MM-dd',                  // 这是组件展示的日期格式
        valueFormat: 'yyyy-MM-dd',
      }, {
        label: 'BOM电子收入',
        children: [{
          label: '支付宝',
          children: [{
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '交易金额',
            prop: 'alipayTradeAmount'
          }, {
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '手续费金额',
            prop: 'alipayTradeServiceAmount'
          }, {
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '银行存款金额',
            prop: 'alipayTradeBankAmount'
          }]
        }, {
          label: '微信',
          children: [{
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '交易金额',
            prop: 'wechartTradeAmount'
          }, {
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '手续费金额',
            prop: 'wechartTradeServiceAmount'
          }, {
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '银行存款金额',
            prop: 'wechartTradeBankAmount'
          }]
        }, {
          label: 'POS',
          children: [{
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '交易金额',
            prop: 'posTradeAmount'
          }, {
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '手续费金额',
            prop: 'posTradeServiceAmount'
          }, {
            type: 'input',
            showSummary: true,
            precision: 2,
            formatter: (row, value, label, column) => {
              return rcaNumberFormat(value, true)
            },
            label: '银行存款金额',
            prop: 'posTradeBankAmount'
          }]
        }]
      }, {
        label: '差异（交易-银行）',
        children: [{
          type: 'input',
          showSummary: true,
          precision: 2,
          formatter: (row, value, label, column) => {
            return rcaNumberFormat(value, true)
          },
          label: 'BOM支付宝',
          prop: 'diffAlipyAmount',
          slot: true
        }, {
          type: 'input',
          showSummary: true,
          precision: 2,
          formatter: (row, value, label, column) => {
            return rcaNumberFormat(value, true)
          },
          label: 'BOM微信',
          prop: 'diffWechartAmount',
          slot: true
        }, {
          type: 'input',
          showSummary: true,
          precision: 2,
          formatter: (row, value, label, column) => {
            return rcaNumberFormat(value, true)
          },
          label: 'POS',
          prop: 'diffPosAmount',
          slot: true
        }]
      }, {
        type: 'select',
        label: '状态',
        prop: 'confirmStatus',
        search: true,
        dicData: [
          {
            label: '已确认',
            value: '1'
          }, {
            label: '未确认',
            value: '0'
          }
        ]
      }
      ]
    }]
}
